## C++类模板（支持嵌套POJO和List）
## 引入必要的头文件
#if ($javaClass)
\#include <nlohmann/json.hpp>
#if ($javaClass.hasStrings)
\#include <string>
#end
#if ($javaClass.hasLists)
\#include <vector>
#end
## 包含自定义类的头文件
#foreach ($customType in $javaClass.customTypes)
\#include "$!{customType}.h"
#end
#end

## 类定义
class $!javaClass.className {
private:
#if ($javaClass)
#foreach ($field in $javaClass.fields)
#if ($field.isList)
    std::vector<$!field.listElementCppType> $!field.name;
#else
    $!field.cppType $!field.name;
#end
#end
#end

public:
    $!{javaClass.className}() = default;

    $!{javaClass.className}(
        #if ($javaClass)
            #foreach ($field in $javaClass.fields)
        #if ($field.isList)
        std::vector<$!field.listElementCppType> $!field.name
        #else
        $!field.cppType $!field.name#if ($foreach.hasNext),#end
        #end
        #end
        #end
    ) {
        #if ($javaClass)
            #foreach ($field in $javaClass.fields)
        this->$!field.name = $!field.name;
            #end
        #end
    }

    #if ($javaClass)
        #foreach ($field in $javaClass.fields)
    #if ($field.isList)
    const std::vector<$!field.listElementCppType>& get$!{field.capitalizedName}() const {
        return $!field.name;
    }

    void set$!{field.capitalizedName}(const std::vector<$!field.listElementCppType>& $!field.name) {
        this->$!field.name = $!field.name;
    }

    #else
    $!field.cppType get$!{field.capitalizedName}() const {
        return $!field.name;
    }

    void set$!{field.capitalizedName}($!field.cppType $!field.name) {
        this->$!field.name = $!field.name;
    }
    #end
        #end
    #end
    
    // Nlohmann/JSON序列化和反序列化方法
    friend void to_json(nlohmann::json& j, const $!javaClass.className& obj) {
        #if ($javaClass)
            #foreach ($field in $javaClass.fields)
        j["$!field.name"] = obj.$!field.name;
            #end
        #end
    }

    friend void from_json(const nlohmann::json& j, $!javaClass.className& obj) {
        #if ($javaClass)
            #foreach ($field in $javaClass.fields)
        j.at("$!field.name").get_to(obj.$!field.name);
            #end
        #end
    }
};